library(codebook)
setwd("C:/Users/BelajiAvvaru/Desktop/Docs/Docs/SMU/MSDS 6306/Project 2/")
ddsdata<-read.csv("CaseStudy2-data.csv",header=T)
codebook(ddsdata)
## No missing values.
knitr::asis_output(data_info)
if (exists("name", meta)) {
glue::glue(
"__Dataset name__: {name}",
.envir = meta)
}
Dataset name: ddsdata
cat(description)
The dataset has N=870 rows and 36 columns. 870 rows have no missing values on any column.
Metadata for search engines
meta <- meta[setdiff(names(meta),
c("creator", "datePublished", "identifier",
"url", "citation", "spatialCoverage",
"temporalCoverage", "description", "name"))]
pander::pander(meta)
knitr::asis_output(survey_overview)
if (detailed_variables || detailed_scales) {
knitr::asis_output(paste0(scales_items, sep = "\n\n\n", collapse = "\n\n\n"))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| ID | numeric | 0 | 1 | 1 | 436 | 870 | 435.5 | 251.2917 | ▇▇▇▇▇ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| Age | numeric | 0 | 1 | 18 | 35 | 60 | 36.82874 | 8.92595 | ▂▇▇▃▂ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| Attrition | factor | FALSE | 1. No, 2. Yes |
0 | 1 | 2 | No: 730, Yes: 140 | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| BusinessTravel | factor | FALSE | 1. Non-Travel, 2. Travel_Frequently, 3. Travel_Rarely |
0 | 1 | 3 | Tra: 618, Tra: 158, Non: 94 | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| DailyRate | numeric | 0 | 1 | 103 | 818 | 1499 | 815.2276 | 401.1163 | ▇▇▇▇▇ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| Department | factor | FALSE | 1. Human Resources, 2. Research & Development, 3. Sales |
0 | 1 | 3 | Res: 562, Sal: 273, Hum: 35 | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| DistanceFromHome | numeric | 0 | 1 | 1 | 7 | 29 | 9.33908 | 8.136704 | ▇▅▂▂▂ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| Education | numeric | 0 | 1 | 1 | 3 | 5 | 2.901149 | 1.023037 | ▂▅▇▆▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| EducationField | factor | FALSE | 1. Human Resources, 2. Life Sciences, 3. Marketing, 4. Medical, 5. Other, 6. Technical Degree |
0 | 1 | 6 | Lif: 358, Med: 270, Mar: 100, Tec: 75 | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| EmployeeCount | numeric | 0 | 1 | 1 | 1 | 1 | 1 | 0 | ▁▁▇▁▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| EmployeeNumber | numeric | 0 | 1 | 1 | 1039 | 2064 | 1029.832 | 604.7893 | ▇▇▇▇▇ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| EnvironmentSatisfaction | numeric | 0 | 1 | 1 | 3 | 4 | 2.701149 | 1.099377 | ▅▆▁▇▇ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| Gender | factor | FALSE | 1. Female, 2. Male |
0 | 1 | 2 | Mal: 516, Fem: 354 | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| HourlyRate | numeric | 0 | 1 | 30 | 66 | 100 | 65.61379 | 20.12716 | ▇▇▆▇▇ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| JobInvolvement | numeric | 0 | 1 | 1 | 3 | 4 | 2.722989 | 0.7036321 | ▁▃▁▇▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| JobLevel | numeric | 0 | 1 | 1 | 2 | 5 | 2.03908 | 1.090112 | ▇▇▃▂▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| JobRole | factor | FALSE | 1. Healthcare Representative, 2. Human Resources, 3. Laboratory Technician, 4. Manager, 5. Manufacturing Director, 6. Research Director, 7. Research Scientist, 8. Sales Executive, 9. Sales Representative |
0 | 1 | 9 | Sal: 200, Res: 172, Lab: 153, Man: 87 | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| JobSatisfaction | numeric | 0 | 1 | 1 | 3 | 4 | 2.709195 | 1.114517 | ▅▅▁▇▇ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| MaritalStatus | factor | FALSE | 1. Divorced, 2. Married, 3. Single |
0 | 1 | 3 | Mar: 410, Sin: 269, Div: 191 | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| MonthlyIncome | numeric | 0 | 1 | 1081 | 4946 | 19999 | 6390.264 | 4597.696 | ▇▅▂▁▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| MonthlyRate | numeric | 0 | 1 | 2094 | 14074 | 26997 | 14325.62 | 7108.382 | ▇▇▇▇▇ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| NumCompaniesWorked | numeric | 0 | 1 | 0 | 2 | 9 | 2.727586 | 2.520443 | ▇▃▂▂▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| Over18 | factor | FALSE | 1. Y | 0 | 1 | 1 | Y: 870 | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| OverTime | factor | FALSE | 1. No, 2. Yes |
0 | 1 | 2 | No: 618, Yes: 252 | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| PercentSalaryHike | numeric | 0 | 1 | 11 | 14 | 25 | 15.2 | 3.67544 | ▇▅▃▂▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| PerformanceRating | numeric | 0 | 1 | 3 | 3 | 4 | 3.151724 | 0.3589596 | ▇▁▁▁▂ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| RelationshipSatisfaction | numeric | 0 | 1 | 1 | 3 | 4 | 2.706897 | 1.102491 | ▅▅▁▇▇ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| StandardHours | numeric | 0 | 1 | 80 | 80 | 80 | 80 | 0 | ▁▁▇▁▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| StockOptionLevel | numeric | 0 | 1 | 0 | 1 | 3 | 0.783908 | 0.857764 | ▇▇▁▂▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| TotalWorkingYears | numeric | 0 | 1 | 0 | 10 | 40 | 11.05287 | 7.513668 | ▇▇▂▁▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| TrainingTimesLastYear | numeric | 0 | 1 | 0 | 3 | 6 | 2.832184 | 1.272665 | ▂▇▇▂▃ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| WorkLifeBalance | numeric | 0 | 1 | 1 | 3 | 4 | 2.781609 | 0.7119769 | ▁▃▁▇▂ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| YearsAtCompany | numeric | 0 | 1 | 0 | 5 | 40 | 6.962069 | 6.021036 | ▇▃▁▁▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| YearsInCurrentRole | numeric | 0 | 1 | 0 | 3 | 18 | 4.204598 | 3.639317 | ▇▃▂▁▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| YearsSinceLastPromotion | numeric | 0 | 1 | 0 | 1 | 15 | 2.168966 | 3.185872 | ▇▁▁▁▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
show_missing_values <- FALSE
if (has_labels(item)) {
missing_values <- item[is.na(haven::zap_missing(item))]
attributes(missing_values) <- attributes(item)
if (!is.null(attributes(item)$labels)) {
attributes(missing_values)$labels <- attributes(missing_values)$labels[is.na(attributes(missing_values)$labels)]
attributes(item)$labels <- attributes(item)$labels[!is.na(attributes(item)$labels)]
}
if (is.double(item)) {
show_missing_values <- length(unique(haven::na_tag(missing_values))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]
# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
any(stringr::str_detect(item_nomiss, stringr::fixed(", "))) &&
!is.null(item_info) &&
(exists("type", item_info) &&
any(stringr::str_detect(item_info$type,
pattern = stringr::fixed("multiple"))))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)
old_height <- knitr::opts_chunk$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is_numeric_or_time_var(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way
if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
if(could_disclose_unique_values(item_nomiss) && is.character(item_nomiss)) {
new_height <- old_height
}
knitr::opts_chunk$set(fig.height = new_height)
}
wrap_at <- knitr::opts_chunk$get("fig.width") * 10
# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (!could_disclose_unique_values(item_nomiss)) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
if (is.character(item_nomiss)) {
char_count <- stringr::str_count(item_nomiss)
attributes(char_count)$label <- item_label
plot_labelled(char_count,
item_name, wrap_at, FALSE, trans = "log1p", "characters")
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}
}
knitr::opts_chunk$set(fig.height = old_height)
0 missing values.
attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| YearsWithCurrManager | numeric | 0 | 1 | 0 | 3 | 17 | 4.14023 | 3.574441 | ▇▂▅▁▁ | NA |
if (show_missing_values) {
plot_labelled(missing_values, item_name, wrap_at)
}
if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info$choices) &&
all(names(na.omit(choices)) == item_info$choices) &&
all(na.omit(choices) == names(item_info$choices))) {
item_info$choices <- NULL
}
item_info$label_parsed <-
item_info$choice_list <- item_info$study_id <- item_info$id <- NULL
pander::pander(item_info)
}
if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}
missingness_report
if (length(md_pattern)) {
if (knitr::is_html_output()) {
rmarkdown::paged_table(md_pattern, options = list(rows.print = 10))
} else {
knitr::kable(md_pattern)
}
}
items
export_table(metadata_table)
jsonld
JSON-LD metadata
The following JSON-LD can be found by search engines, if you share this codebook publicly on the web.
{
"name": "ddsdata",
"datePublished": "2020-04-16",
"description": "The dataset has N=870 rows and 36 columns.\n870 rows have no missing values on any column.\n\n\n## Table of variables\nThis table contains variable names, labels, and number of missing values.\nSee the complete codebook for more.\n\n|name |label | n_missing|\n|:------------------------|:-----|---------:|\n|ID |NA | 0|\n|Age |NA | 0|\n|Attrition |NA | 0|\n|BusinessTravel |NA | 0|\n|DailyRate |NA | 0|\n|Department |NA | 0|\n|DistanceFromHome |NA | 0|\n|Education |NA | 0|\n|EducationField |NA | 0|\n|EmployeeCount |NA | 0|\n|EmployeeNumber |NA | 0|\n|EnvironmentSatisfaction |NA | 0|\n|Gender |NA | 0|\n|HourlyRate |NA | 0|\n|JobInvolvement |NA | 0|\n|JobLevel |NA | 0|\n|JobRole |NA | 0|\n|JobSatisfaction |NA | 0|\n|MaritalStatus |NA | 0|\n|MonthlyIncome |NA | 0|\n|MonthlyRate |NA | 0|\n|NumCompaniesWorked |NA | 0|\n|Over18 |NA | 0|\n|OverTime |NA | 0|\n|PercentSalaryHike |NA | 0|\n|PerformanceRating |NA | 0|\n|RelationshipSatisfaction |NA | 0|\n|StandardHours |NA | 0|\n|StockOptionLevel |NA | 0|\n|TotalWorkingYears |NA | 0|\n|TrainingTimesLastYear |NA | 0|\n|WorkLifeBalance |NA | 0|\n|YearsAtCompany |NA | 0|\n|YearsInCurrentRole |NA | 0|\n|YearsSinceLastPromotion |NA | 0|\n|YearsWithCurrManager |NA | 0|\n\n### Note\nThis dataset was automatically described using the [codebook R package](https://rubenarslan.github.io/codebook/) (version 0.8.2).",
"keywords": ["ID", "Age", "Attrition", "BusinessTravel", "DailyRate", "Department", "DistanceFromHome", "Education", "EducationField", "EmployeeCount", "EmployeeNumber", "EnvironmentSatisfaction", "Gender", "HourlyRate", "JobInvolvement", "JobLevel", "JobRole", "JobSatisfaction", "MaritalStatus", "MonthlyIncome", "MonthlyRate", "NumCompaniesWorked", "Over18", "OverTime", "PercentSalaryHike", "PerformanceRating", "RelationshipSatisfaction", "StandardHours", "StockOptionLevel", "TotalWorkingYears", "TrainingTimesLastYear", "WorkLifeBalance", "YearsAtCompany", "YearsInCurrentRole", "YearsSinceLastPromotion", "YearsWithCurrManager"],
"@context": "http://schema.org/",
"@type": "Dataset",
"variableMeasured": [
{
"name": "ID",
"@type": "propertyValue"
},
{
"name": "Age",
"@type": "propertyValue"
},
{
"name": "Attrition",
"value": "1. No,\n2. Yes",
"@type": "propertyValue"
},
{
"name": "BusinessTravel",
"value": "1. Non-Travel,\n2. Travel_Frequently,\n3. Travel_Rarely",
"@type": "propertyValue"
},
{
"name": "DailyRate",
"@type": "propertyValue"
},
{
"name": "Department",
"value": "1. Human Resources,\n2. Research & Development,\n3. Sales",
"@type": "propertyValue"
},
{
"name": "DistanceFromHome",
"@type": "propertyValue"
},
{
"name": "Education",
"@type": "propertyValue"
},
{
"name": "EducationField",
"value": "1. Human Resources,\n2. Life Sciences,\n3. Marketing,\n4. Medical,\n5. Other,\n6. Technical Degree",
"@type": "propertyValue"
},
{
"name": "EmployeeCount",
"@type": "propertyValue"
},
{
"name": "EmployeeNumber",
"@type": "propertyValue"
},
{
"name": "EnvironmentSatisfaction",
"@type": "propertyValue"
},
{
"name": "Gender",
"value": "1. Female,\n2. Male",
"@type": "propertyValue"
},
{
"name": "HourlyRate",
"@type": "propertyValue"
},
{
"name": "JobInvolvement",
"@type": "propertyValue"
},
{
"name": "JobLevel",
"@type": "propertyValue"
},
{
"name": "JobRole",
"value": "1. Healthcare Representative,\n2. Human Resources,\n3. Laboratory Technician,\n4. Manager,\n5. Manufacturing Director,\n6. Research Director,\n7. Research Scientist,\n8. Sales Executive,\n9. Sales Representative",
"@type": "propertyValue"
},
{
"name": "JobSatisfaction",
"@type": "propertyValue"
},
{
"name": "MaritalStatus",
"value": "1. Divorced,\n2. Married,\n3. Single",
"@type": "propertyValue"
},
{
"name": "MonthlyIncome",
"@type": "propertyValue"
},
{
"name": "MonthlyRate",
"@type": "propertyValue"
},
{
"name": "NumCompaniesWorked",
"@type": "propertyValue"
},
{
"name": "Over18",
"value": "1. Y",
"@type": "propertyValue"
},
{
"name": "OverTime",
"value": "1. No,\n2. Yes",
"@type": "propertyValue"
},
{
"name": "PercentSalaryHike",
"@type": "propertyValue"
},
{
"name": "PerformanceRating",
"@type": "propertyValue"
},
{
"name": "RelationshipSatisfaction",
"@type": "propertyValue"
},
{
"name": "StandardHours",
"@type": "propertyValue"
},
{
"name": "StockOptionLevel",
"@type": "propertyValue"
},
{
"name": "TotalWorkingYears",
"@type": "propertyValue"
},
{
"name": "TrainingTimesLastYear",
"@type": "propertyValue"
},
{
"name": "WorkLifeBalance",
"@type": "propertyValue"
},
{
"name": "YearsAtCompany",
"@type": "propertyValue"
},
{
"name": "YearsInCurrentRole",
"@type": "propertyValue"
},
{
"name": "YearsSinceLastPromotion",
"@type": "propertyValue"
},
{
"name": "YearsWithCurrManager",
"@type": "propertyValue"
}
]
}`